#include<cstdio>
bool aTrue,bTrue;
int judge(int m,int n,int p)
{
	if(aTrue)return 0;
	if(m==1 && n==1)
	{
		aTrue = true;
		return 0;
	}
	if(n==1)bTrue = true;
	while(p>1)
	{
		if(m%p == 0)judge(m/p,n,p-1);
		if(n%p == 0)judge(m,n/p,p-1);
		p--;
	}
	return 0;
}
int main()
{
	freopen("test.in","r",stdin);
	freopen("test.out","w",stdout);
	int a,b;
	while(scanf("%d%d",&a,&b)!=EOF)
	{
		if(a<b)
		{
			int temp=a;
			a=b;
			b=temp;
		}
		aTrue = false ;
		bTrue = false;
		judge(a,b,100);
		if(!aTrue && bTrue)printf("%d\n",b);
		else printf("%d\n",a);
	}
	return 0;
}


